package com.lmx.repoDomain.tmodel;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ForeignKey;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import com.lmx.repoDomain.tmodel.business.User;

import io.katharsis.resource.annotations.JsonApiIncludeByDefault;
import io.katharsis.resource.annotations.JsonApiResource;
import io.katharsis.resource.annotations.JsonApiToMany;
import io.katharsis.resource.annotations.JsonApiToOne;


/**
 * 老人药品对照表
 */
@JsonApiResource(type = "customerdrug")
@Table(name = "tnb_customer_drug")
@Entity
public class CustomerDrug extends BaseEntity {
	private String remark;// 备注

	private User lastUpdateUser;// 更新操作者userid

	private Integer createDateTime;// 创建时间

	private User createUser;

	private Integer lastUpdateDateTime;// 更新时间

	private Drug drug;

	private Customer customer;

	private Double drugNum;

	private List<CustomerDrugProjectExe> exes;

	private String gatherStaff;// 收缴人
	
	private Double addDrugNum; 
	
	private Dicttype addFlag;

	@Transient
	public Double getAddDrugNum() {
		return addDrugNum;
	}

	public void setAddDrugNum(Double addDrugNum) {
		this.addDrugNum = addDrugNum;
	}

	@Transient
	@JsonApiToOne
	public Dicttype getAddFlag() {
		return addFlag;
	}

	public void setAddFlag(Dicttype addFlag) {
		this.addFlag = addFlag;
	}

	@Column(name = "gather_staff")
	public String getGatherStaff() {
		return gatherStaff;
	}

	public void setGatherStaff(String gatherStaff) {
		this.gatherStaff = gatherStaff;
	}

	@Column(name = "drug_num")
	public Double getDrugNum() {
		return drugNum;
	}

	public void setDrugNum(Double drugNum) {
		this.drugNum = drugNum;
	}

	public void setExes(List<CustomerDrugProjectExe> exes) {
		this.exes = exes;
	}

	@JsonApiToMany
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "customerDrug")
	public List<CustomerDrugProjectExe> getExes() {
		return exes;
	}

	public CustomerDrug() {

	}

	@Column(name = "createDateTime")
	public Integer getCreateDateTime() {
		return createDateTime;
	}

	public void setCreateDateTime(Integer createDateTime) {
		this.createDateTime = createDateTime;
	}

	@Column(name = "lastUpdateDateTime")
	public Integer getLastUpdateDateTime() {
		return lastUpdateDateTime;
	}

	public void setLastUpdateDateTime(Integer lastUpdateDateTime) {
		this.lastUpdateDateTime = lastUpdateDateTime;
	}

	@JsonApiToOne
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "createuser_id", foreignKey = @ForeignKey(name = "null"))
	public User getCreateUser() {
		return createUser;
	}

	public void setCreateUser(User createUser) {
		this.createUser = createUser;
	}

	@JsonApiToOne
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "lastupdateuser_id", foreignKey = @ForeignKey(name = "null"))
	public User getLastUpdateUser() {
		return lastUpdateUser;
	}

	public void setLastUpdateUser(User lastUpdateUser) {
		this.lastUpdateUser = lastUpdateUser;
	}

	@Column(name = "remark")
	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	@JsonApiToOne
	@ManyToOne(fetch = FetchType.LAZY)
    @JsonApiIncludeByDefault
	@Fetch(FetchMode.JOIN)
	@JoinColumn(name = "drug_id", foreignKey = @ForeignKey(name = "null"))
	public Drug getDrug() {
		return drug;
	}

	public void setDrug(Drug drug) {
		this.drug = drug;
	}

	@JsonApiToOne
	@ManyToOne(fetch = FetchType.LAZY)
    @JsonApiIncludeByDefault
	@Fetch(FetchMode.JOIN)
	@JoinColumn(name = "customer_id", foreignKey = @ForeignKey(name = "null"))
	public Customer getCustomer() {
		return customer;
	}

	public void setCustomer(Customer customer) {
		this.customer = customer;
	}
}
